package com.baseproject.datasource.remote;

import java.util.Map;

import okhttp3.ResponseBody;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.QueryMap;
import retrofit2.http.Streaming;
import retrofit2.http.Url;
import rx.Observable;


public class RetrofitStrategy implements BaseRemoteStrategy {

    private final YcsdService mService = RetrofitUtil.createService(YcsdService.class);

    public RetrofitStrategy() {

    }

    @Override
    public Observable<ResponseBody> getList(String url, String token, Map<String, String> queryParams) {
        return mService.getList(url, token, queryParams);
    }

    @Override
    public Observable<ResponseBody> downloadFile(String url) {
        return mService.downFile(url);
    }

    @Override
    public Observable<ResponseBody> httpPost(String url, Map<String, String> params, String token) {
        return mService.httpPost(url, params, token);
    }

    public interface YcsdService {

        @GET
        Observable<ResponseBody> getList(@Url String url, @Header("x-token") String token, @QueryMap Map<String, String> param);

        @Streaming
        @GET
        Observable<ResponseBody> downFile(@Url String url);

        @POST
        Observable<ResponseBody> httpPost(@Url String url, @QueryMap Map<String, String> params, @Header("x-token") String token);
    }
}
